package com.example.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.mail.SimpleMailMessage;

@Configuration
public class MailConfig {

    @Value("${spring.mail.host}")
    private String host;

    @Value("${spring.mail.username}")
    private String username;

    @Value("${spring.mail.password}")
    private String password;

    @Value("${spring.mail.from}")
    private String from;
    @Bean
    public SimpleMailMessage simpleMailMessage(){
        SimpleMailMessage mail = new SimpleMailMessage();
        mail.setTo(username);
        mail.setFrom(from);
        return mail;
    }

    /*@Bean
    public JavaMailSender getJavaMailSender() {
        JavaMailSenderImpl mailSender = new JavaMailSenderImpl();
        mailSender.setHost(host);
       // mailSender.setPort(port);
        mailSender.setUsername(username);
        mailSender.setPassword(password);

        // 其他配置，如协议、SSL/TLS等
        Properties props = mailSender.getJavaMailProperties();
        props.put("mail.smtp.auth", "true");
        props.put("mail.smtp.starttls.enable", "true");
        // ...

        return mailSender;
    }*/
}